﻿using MyX.Message;
using MyX.Work;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyX.Bus
{
    public class XWorkStatusBus : XMessageBus<XWorkStatus>
    {
        public XWorkStatusBus(XIMQ mq) : base("Work", mq)
        {
        }

        protected override void ReceiveCore(XWorkStatus message)
        {
            foreach (var work in WorkTables.HandleWorks)
            {
                if (work.Filter(message))
                    work.Do(message);
            }
        }

        protected override void SendCore(XWorkStatus message)
        {
            message.Check();
        }
    }
}
